export default {
    namespace: 'player',
    state: {
        data: [
            {
                id: 'player0000',
                user_name: 'test_player_0',
                name: '玩家1',
                store_id: 'store0000',
                store_name: '测试店铺',
                gender_code: '1',
                gender_name: '男',
                player_type_code: '0',
                player_type_name: 'VIP会员',
                birthday: '2000-01-01',
                account_id: 'vip_card_0',
                operator_id: 'employee0000',
                operator_name: '测试员工',
                create_date: '2017-03-03 08:08:08',
                status: '1',
            },
            {
                id: 'player0001',
                user_name: 'test_player_1',
                name: '玩家2',
                store_id: 'store0000',
                store_name: '测试店铺',
                gender_code: '1',
                gender_name: '男',
                player_type_code: '1',
                player_type_name: '散客',
                birthday: '2000-01-01',
                account_id: 'vip_card_0',
                operator_id: 'employee0000',
                operator_name: '测试员工',
                create_date: '2017-03-03 08:08:08',
                status: '1',
            },
            {
                id: 'player0003',
                user_name: 'test_player_1',
                name: '玩家233',
                store_id: 'store0000',
                store_name: '测试店铺',
                gender_code: '1',
                gender_name: '男',
                player_type_code: '1',
                player_type_name: '散客',
                birthday: '2000-01-01',
                account_id: 'vip_card_0',
                operator_id: 'employee0000',
                operator_name: '测试员工',
                create_date: '2017-03-03 08:08:08',
                status: '1',
            },
        ],
        editorData: {},
        visible: false,
    },
    subscriptions: {},
    effects: {},
    reducers: {
        setState(state, { payload }) {
            return {
                ...state,
                ...payload,
            };
        },
        editorVisible(state, { payload: { editorData } = {} }) {
            // 隐藏时不清数据,避免因为隐藏动作慢而界面显示为新建
            if (editorData) {
                return {
                    ...state,
                    visible: !!editorData,
                    editorData,
                };
            } else {
                return {
                    ...state,
                    visible: false,
                };
            }
        },
    }
};
